package com.woniuxy02;

import java.util.Scanner;

public class Test04 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("运算数1");
        int numA = scanner.nextInt();
        System.out.println("运算数2");
        int numB = scanner.nextInt();
        System.out.println("运算符号+-*/");
        String operator = scanner.next();
        int result = 0;
        switch (operator) {
            case "+":
                result=numA+numB;
                break;
            case "-":
                result=numA-numB;
                break;
            case "*":
                result=numA*numB;
                break;
            case "/":
                if (numB!=0) {
                    result=numA/numB;
                }else{
                    System.out.println("除数不能为0");
                }
                break;
            default:
                System.out.println("运算符错误");
                break;
        }

        if (operator.equals("+")||operator.equals("-")||operator.equals("*")||(operator.equals("/")&&numB!=0)) {
            System.out.println(numA+operator+numB+"="+result);
        }
    }
}
